package cn.bdqn.Bean.dao.impl;

import cn.bdqn.Bean.Working;
import cn.bdqn.Bean.dao.WorkingDao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

public class WorkingDaoImpl extends BaseDao  implements WorkingDao {
    @Override
    public List<cn.bdqn.Bean.Working> getAll() {
        Connection con=null;
        PreparedStatement pre=null;
        ResultSet res=null;
        List<Working> List=new ArrayList<>();
        try{
            con=getConn();
            String sql="select * from Working";
            pre=con.prepareStatement(sql);
            res=pre.executeQuery();
            while (res.next()){
                Working working=new Working(res.getInt("id"),
                res.getString("title"),
                res.getString("content"),
                res.getDate("createDate"),
                res.getInt("tybe")
                );
                List.add(working);
            }

        }catch (Exception e){

        }finally {
            closeAll(con,pre,res);
        }
        return List;
    }
}
